package com.acwing.partition11;

import java.io.*;

public class AC1022宠物小精灵之收服 {

    private static final int N = 1010, M = 510, K = 110;
    private static int[][] f = new int[N][M];
    private static int[] v1 = new int[K], v2 = new int[K];
    private static int n, m, k;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = nextInt(); m = nextInt(); k = nextInt();
        for (int i = 1; i <= k; i++) {
            v1[i] = nextInt();
            v2[i] = nextInt();
        }
        for (int i = 1; i <= k; i++) {
            for (int a = n; a >= v1[i]; a--) {
                for (int b = m; b >= v2[i]; b--) {
                    f[a][b] = Math.max(f[a][b], f[a - v1[i]][b - v2[i]] + 1);
                }
            }
        }
        int cnt = f[n][m - 1], ans = m;
        for (int i = m; i >= 1; i--) {
            if (f[n][i] == f[n][i - 1] && f[n][i] == cnt) ans = i - 1;
        }
        writer.format("%d %d", cnt, m - ans);
        writer.flush();
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
